BEGIN TRANSACTION GO ALTER TABLE dbo.gen_Appconfig ADD DefaultStoreID smallint NOT NULL CONSTRAINT DF_gen_Appconfig_DefaultStoreId DEFAULT 1, DefaulPurchaseRate tinyint NOT NULL CONSTRAINT DF_gen_Appconfig_DefaulPurchaseRate DEFAULT 0, DefaultSaleRate tinyint NOT NULL CONSTRAINT DF_gen_Appconfig_DefaultSaleRate DEFAULT 0 GO COMMIT ---------------------------- BEGIN TRANSACTION GO ALTER TABLE dbo.gen_PartiesInfo ADD EmployeeID smallint NULL GO COMMIT BEGIN TRANSACTION GO UPDATE gen_PartiesInfo SET EmployeeID = 10, CrLimit = AccountNo WHERE (SectorID = 13) UPDATE gen_StaffGroups SET AssociatedAccouunt=230000, ParentAccount=200000 GO COMMIT ---------------------------- SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER VIEW [dbo].[vw_PartiesInfo] AS SELECT dbo.gen_AreaInfo.RegionID, dbo.gen_RegionInfo.RegionTitle, dbo.gen_PartiesInfo.AreaID, dbo.gen_AreaInfo.AreaTitle, dbo.gen_PartiesInfo.SectorID, dbo.gen_SectorInfo.SectorTitle, dbo.gen_PartiesInfo.PartyTypeID, dbo.gen_PartyTypesInfo.PartyTypeTitle, dbo.gen_PartiesInfo.PartyID, dbo.gen_PartiesInfo.PartyCode, dbo.gen_PartiesInfo.PartyTitle, dbo.gen_PartiesInfo.AccountNo, ISNULL(Opening.Opening, 0) AS Opening, dbo.gen_PartiesInfo.BusinessType, dbo.gen_PartiesInfo.Address, dbo.gen_PartiesInfo.City, dbo.gen_PartiesInfo.Country, dbo.gen_PartiesInfo.HomePhone, dbo.gen_PartiesInfo.MobilePhone, dbo.gen_PartiesInfo.NICNO, dbo.gen_PartiesInfo.HireDate, dbo.gen_PartiesInfo.Email, dbo.gen_PartiesInfo.Remarks, dbo.gen_PartiesInfo.Discontinue, dbo.gen_PartiesInfo.ShowIn, dbo.gen_PartiesInfo.EntryDateTime, dbo.gen_PartiesInfo.HostName, dbo.gen_PartiesInfo.CrLimit, dbo.gen_PartiesInfo.Balance, dbo.gen_PartiesInfo.EmployeeID, dbo.Employees.EmployeeCode, dbo.Employees.EmployeeName FROM dbo.gen_SectorInfo RIGHT OUTER JOIN dbo.gen_PartyTypesInfo RIGHT OUTER JOIN dbo.gen_PartiesInfo LEFT OUTER JOIN dbo.Employees ON dbo.gen_PartiesInfo.EmployeeID = dbo.Employees.EmployeeID LEFT OUTER JOIN (SELECT dbo.SessionBalances.AccountNo, SUM(ISNULL(dbo.SessionBalances.OpeningBal, 0)) + SUM(ISNULL(dbo.SessionBalances.DrAmount, 0)) - SUM(ISNULL(dbo.SessionBalances.CrAmount, 0)) AS Opening FROM dbo.SessionBalances RIGHT OUTER JOIN dbo.gen_PartiesInfo AS gen_PartiesInfo_1 ON dbo.SessionBalances.AccountNo = gen_PartiesInfo_1.AccountNo GROUP BY dbo.SessionBalances.AccountNo) AS Opening ON dbo.gen_PartiesInfo.AccountNo = Opening.AccountNo ON dbo.gen_PartyTypesInfo.PartyTypeID = dbo.gen_PartiesInfo.PartyTypeID ON dbo.gen_SectorInfo.SectorID = dbo.gen_PartiesInfo.SectorID LEFT OUTER JOIN dbo.gen_AreaInfo LEFT OUTER JOIN dbo.gen_RegionInfo ON dbo.gen_AreaInfo.RegionID = dbo.gen_RegionInfo.RegionID ON dbo.gen_PartiesInfo.AreaID = dbo.gen_AreaInfo.AreaID